<template>
	<view class="content-box">
		<view v-if="dataList.length > 0" class="card-box">
			<view v-for="item,index in dataList" :key="index" class="card">
				<view class="card-num">
					订单编号: {{item.sn}}
				</view>
				<view v-for="items in item.orderItems" class="card-center">
					<view class="center-img">
						<image :src="items.thumbnail"></image>
					</view>
					<view class="center-right">
						<view class="right-top u-ellipsis-2">
							{{items.name}}
						</view>
						<view class="right-cen">
							数量:{{items.quantity}}
						</view>
						<view class="right-btm">
							￥{{items.price}}
						</view>
					</view>
				</view>
				<view class="card-btm">
					<view class="">
						订单金额：￥{{item.price}}
					</view>
					<view class="" style="color: red;margin-left: 20rpx;">
						补贴金额：￥{{item.commission}}
					</view>
				</view>
			</view>
			<u-loadmore height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
		</view>
		<ljshop-empty-cart v-else :image="'https://image.hzwltb69.com/app/date/2023/暂无消息.png'" tipText="暂无明细">
		</ljshop-empty-cart> 
	</view>
</template>

<script>
	export default{
		data(){
			return{
				dataList: [],
				page: 0,
				loadStatus: 'nomore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
			}
		},
		created() {
			this.getDataList()
		},
		onReachBottom(){
			if(this.onEnd) return
			this.page += 1
			this.getDataList()
		},
		methods:{
			getDataList(){
				this.loadStatus = 'loading'
				this.$http('store.getSmailDateList',{
					UId: uni.getStorageSync('UId'),
					page: this.page,
					size: 10
				})
				.then(res =>{
					if(res.length > 0){
						this.dataList.length == 0 ? this.dataList = res : this.dataList = this.dataList.concat(res)
						if(res.length < 10){
							this.onEnd = true
							this.loadStatus = 'nomore'
						}else{
							this.loadStatus = 'loadmore'
						}
					}else{
						this.onEnd = true
						this.loadStatus = 'nomore'
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content-box{
		padding: 20rpx;
		width: 100%;
		.card-box{
			width: 100%;
			.card{
				width: 100%;
				// height: 320rpx;
				background: #fff;
				display: flex;
				flex-direction: column;
				border-radius: 25rpx;
				padding: 20rpx;
				margin-bottom: 20rpx;
				.card-num{
					font-size: 25rpx;
					color: #999999;
				}
				.card-center{
					display: flex;
					margin-top: 20rpx;
					.center-img{
						width: 180rpx;
						height: 180rpx;
						// background: red;
						border-radius: 10rpx;
						overflow: hidden;
						image{
							width: 180rpx;
							height: 180rpx;
						}
					}
					.center-right{
						margin-left: 20rpx;
						display: flex;
					    flex-direction: column;
						// justify-content: space-between;
						.right-top{
							width: 430rpx;
							// background: red;
							height: 80rpx;
							font-size: 27rpx;
						}
						.right-cen{
							font-size: 24rpx;
							color: #999999;
						}
						.right-btm{
							font-size: 26rpx;
							font-weight: 600;
							margin-top: 20rpx;
						}
					}
				}
				.card-btm{
					display: flex;
					width: 100%;
					justify-content: flex-end;
					font-size: 26rpx;
					margin-top: 15rpx;
					color: #999999;
				}
			}
		}
	}
</style>